package com.osmino.contacts.list;

import android.content.Context;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.view.View;
import android.widget.ImageView;
import com.osmino.contacts.R;
import com.osmino.core.utils.view.Backgroung;

public class ContactViewRingtoneItem extends ContactViewBaseItem {

	private Uri mRingtoneUri;
	
	public ContactViewRingtoneItem(Context context, IContactViewController controller) {
		super(context, controller);
		mRingtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
	}

	@Override
	public void onClick(View v) {
	}

	@Override
	public void setImagesTo(ImageView iv1, ImageView iv2) {
		iv1.setImageDrawable(null);
		Backgroung.setResource(iv2, R.drawable.contact_view_drop_ic_down, R.drawable.contact_view_drop_ic_down_active);
	}

	public void setRingtone(Uri ringtoneUri) {
		mRingtoneUri = ringtoneUri;
		Ringtone ringtone = RingtoneManager.getRingtone(getContext(), mRingtoneUri);
		String title = getResources().getString(R.string.str_default);
		if (ringtone != null) {
			title = ringtone.getTitle(getContext());
		}
		setText1(title);
		setText2(getResources().getString(R.string.ringtone));
	}
	
	public Uri getRingtoneUri() {
		return mRingtoneUri;
	}
}
